package  com.ciip.cloud.core.ycg.controller.web;



import com.ciip.cloud.core.ycg.model.TemplateModel;
import com.ciip.cloud.core.common.vo.ResponseMessage;
import com.ciip.cloud.core.ycg.service.TemplateModelService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;


/**
 * Title:  TemplateModelController
 * Description: 请填写描述信息
 * @author   yls
 * @created  2020年03月06日 10:28:20 星期五
 */
@Api(value = "请输入模块名称")
@RestController
@RequestMapping(CommonConstant.ApiPath.V1+ YCGCommonConstant.ApiAuth.AUTHC+"/templateModel")
public class TemplateModelController {

    @Autowired
    private TemplateModelService templateModelService;


    /**
     * 详情
     * @param id
     * @return
     */
    @ApiOperation(value = "详情")
    @GetMapping(value = "/detail")
    public ResponseMessage detail(@RequestParam(value = "id",required = true) Long id){
        return   templateModelService.detail(id);
    }


    /**
     * 列表
     * @return
     */
    @ApiOperation(value = "列表")
    @GetMapping(value = "/list")
    public ResponseMessage list(){
        return  templateModelService.list();
    }


      /* 列表-分页
     * @param request
     * @param pageNumber 当前页
     * @param pageSize   每页显示记录数
     * @return
     */
    @ApiOperation(value = "分页列表")
    @GetMapping(value = "/pageList")
    public ResponseMessage pageList(@RequestParam(value = "pageNumber",required = false,defaultValue = "1") Integer pageNumber,
                                    @RequestParam(value = "pageSize",required = false,defaultValue = "10") Integer pageSize,
                                    HttpServletRequest request){
        return  templateModelService.pageList(pageNumber,pageSize,request);
    }



    /**
     * 新增操作
     * @param request
     * @param
     * @return
     */
    @ApiOperation(value = "保存")
    @PostMapping(value = "/save")
    public ResponseMessage save(TemplateModel  templateModel, HttpServletRequest request){
       return   templateModelService.save( templateModel,request);
    }





    /**
     * 更新操作
     * @param request
     * @return
     */
    @ApiOperation(value = "更新")
    @PostMapping(value = "/update")
    public ResponseMessage  update(TemplateModel  templateModel, HttpServletRequest request){
        return   templateModelService.update( templateModel,request);
    }



    /**
     * 删除操作
     * @return
     */
    @ApiOperation(value = "删除")
    @PostMapping(value = "/delete")
    public ResponseMessage deleteById(@RequestParam(value = "id",required = true) Long id){
        return   templateModelService.deleteById(id);
    }


}
